package org.springblade.modules.admin.task.feishu;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springblade.modules.admin.service.IElevatorRepeatFaultLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Date 16:15 2024/9/25
 * @Description {
 *   重复故障电梯
 * }
 * @Author lsay
 **/
@Component
@Slf4j
public class RepeatFaultElevatorJob {

	@Autowired
	private IElevatorRepeatFaultLogService elevatorRepeatFaultLogService;

	/**
	 * 定时任务：每日9:30 13:30
	 */
	//@Scheduled(cron = "0 30 9,13 * * ?")
	@XxlJob(value = "selectRepeatFaultElevator")
	public void selectRepeatFaultElevator() {

		XxlJobHelper.handleSuccess("获取重复故障电梯-方法(selectRepeatFaultElevator)-[执行]开始");

		List<String> tenantList = new ArrayList<>();
		tenantList.add("592800");
		elevatorRepeatFaultLogService.selectRepeatFaultElevator(tenantList);
		// 生成重复故障电梯数据
		try {
//			elevatorService.updateElevatorMaintainStatusDay();
			XxlJobHelper.handleSuccess("获取重复故障电梯-方法(selectRepeatFaultElevator)-[执行]成功");
		} catch (Exception e) {
			XxlJobHelper.handleSuccess("获取重复故障电梯-方法(selectRepeatFaultElevator)-[执行]失败" + e);
		}

	}

	/**
	 * 定时任务：每日9:30 13:30
	 */
	//@Scheduled(cron = "0 30 9,13 * * ?")
	@XxlJob(value = "selectRepeatFaultElevatorPlan")
	public void selectRepeatFaultElevatorPlan() {

		XxlJobHelper.handleSuccess("获取电梯维修工单事件-方法(selectRepeatFaultElevator)-[执行]开始");

		List<String> tenantList = new ArrayList<>();
		tenantList.add("592800");
		elevatorRepeatFaultLogService.selectRepeatFaultElevatorPlan(tenantList);
		// 生成重复故障电梯数据
		try {
//			elevatorService.updateElevatorMaintainStatusDay();
			XxlJobHelper.handleSuccess("获取电梯维修工单事件-方法(selectRepeatFaultElevator)-[执行]成功");
		} catch (Exception e) {
			XxlJobHelper.handleSuccess("获取电梯维修工单事件-方法(selectRepeatFaultElevator)-[执行]失败" + e);
		}

	}

}
